Network Address Translation.html


* created: 2026-05-11T00:00
* modified: 2026-05-11T00:20

title

Title

description

Description

Network Address Translation (NAT)

Mapping private IP addresses to public IP addresses. Each local IP address gets its own port on the public IP, allowing many devices to share a single public address.

How it works

A home router sits between your LAN and the internet. When a device sends a packet out:

  1. The router replaces the private source IP (192.168.1.x) with its public IP
  2. It records the mapping in a NAT table: (private IP, private port) <-> public port
  3. When a reply arrives, the router looks up the table and forwards the packet back to the correct internal device

NAT Traversal

When two peers are both behind NAT, direct connection is non-trivial. Common techniques: